
package pp.strategy.task;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import pp.IProjectJobStrategy;
import properties.AutoBGProperties;

public class HandTaskStrategy implements IProjectJobStrategy {

    @Override
    public Task jobId(JSONArray jsonArray, AutoBGProperties autoBGProperties) {
        for (Object o : jsonArray) {
            JSONObject o1 = (JSONObject) o;
            String name = o1.getString("name");
            if (name.equalsIgnoreCase(autoBGProperties.getSelectTask())) {
                return new Task(o1.getString("id"), o1.getString("name"));
            }
        }
        String id = jsonArray.getJSONObject(0).getString("id");
        String name = jsonArray.getJSONObject(0).getString("name");
        return new Task(id, name);
    }
}
